package com.ibm.risk.irmp.base.service.client;

import com.ibm.risk.irmp.common.auth.session.UserSessionStore;
import com.ibm.risk.irmp.common.auth.vo.LoginUser;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.HttpExchange;
import org.springframework.web.service.annotation.PutExchange;

@HttpExchange("/auth/session")
@CacheConfig(cacheNames = "IrmpLoginDataCache")
public interface UserSessionStoreServiceClient extends UserSessionStore {
    @Override
    @PutExchange("/tokens/{token}")
    @CacheEvict(key = "'UserSessionStore.token.' + #p0")
    void setLoginUser(@PathVariable String token, @RequestBody LoginUser loginUser);

    @Override
    @GetExchange("/tokens/{token}")
    @Cacheable(key = "'UserSessionStore.token.' + #p0")
    LoginUser getLoginUser(@PathVariable String token);
}
